<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box1 {
            width: 200px;
            height: 200px;
            background-color: pink;
        }
        div{
            margin-top: 20px;
        }
        button{
            display: block;
        }
        img{
          margin-top: 5px;
        }
        .change{
            background-color: #ff6700;
            font-size: 18px;
            color: #fff;
        }
    </style>
</head>

<body>
    <div class='box1'>盒子11</div>
    <div>
        <button id="btn">切换显示隐藏图片</button>
        <img src="images/tao.png" alt="">
    </div>
    <script>
        //1.改变盒子属性
        var div = document.querySelector('.box1');
        div.onclick = function () {
           this.className = 'box1 change';
        }

        //2.隐藏图片
        var btns = document.querySelector('#btn');
        var img = document.querySelector('img');
        var flag = 0;
        btns.onclick = function() {
            if(flag == 0) {
                img.style.display = 'none';
                flag = 1;
            }else{
                img.style.display = 'block';
                flag = 0;
            }
        }
    </script>
</body>

</html>